package com.mybatisflex.test.manger;

import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.service.IService;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.mybatisflex.test.entity.Account;
import com.mybatisflex.test.mapper.AccountMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import static com.mybatisflex.test.entity.table.AccountTableDef.ACCOUNT;

/**
 * @author mosue
 * @date 2024/5/27
 * @Description
 */
@Component
@Slf4j
@RequiredArgsConstructor
public class AccountManger extends ServiceImpl<AccountMapper, Account> implements IService<Account> {

    public Account selectAccountByUserName(String userName) {
        QueryWrapper wrapper = QueryWrapper.create()
                .select(ACCOUNT.ALL_COLUMNS)
                .from(ACCOUNT)
                .where(ACCOUNT.USER_NAME.eq(userName));
        return this.mapper.selectOneByQuery(wrapper);
    }
}
